package com.xingongchang.baolebei.protocol;

import org.json.JSONException;
import org.json.JSONObject;
import com.external.activeandroid.Model;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;

/**
 * 帖子用户资料
 * @author luohao
 */
@Table(name = "USER_INFO")
public class USER_INFO extends Model {

	@Column(name = "email")
	public String email;

	@Column(name = "credits")
	public int credits;

	@Column(name = "birthday")
	public String birthday;

	@Column(name = "friends")
	public int friends;

	@Column(name = "posts")
	public int posts;

	@Column(name = "sex")
	public int sex;
	
	@Column(name = "sharings")
	public int sharings;
	
	@Column(name = "user_id")
	public int user_id;
	
	@Column(name = "user_name")
	public String user_name;
	
	@Column(name = "user_photo")
	public String user_photo;
	
	@Column(name = "nickname")
	public String nickname;
	

	public static USER_INFO fromJson(JSONObject jsonObject)
			throws JSONException {
		if (null == jsonObject) {
			return null;
		}

		USER_INFO userinfo = new USER_INFO();

		userinfo.credits = jsonObject.optInt("credits");
		
		userinfo.friends = jsonObject.optInt("friends");
		
		userinfo.posts = jsonObject.optInt("posts");
		
		userinfo.sex = jsonObject.optInt("sex");
		
		userinfo.sharings = jsonObject.optInt("sharings");

		userinfo.user_id = jsonObject.optInt("user_id");

		userinfo.email = jsonObject.optString("email");

		userinfo.birthday = jsonObject.optString("birthday");

		userinfo.user_name = jsonObject.optString("user_name");

		userinfo.user_photo = jsonObject.optString("user_photo");
		
		userinfo.nickname=jsonObject.optString("nickname");

		return userinfo;
	}

}
